Skip to content

Conversation

@gfortaine
Copy link
Contributor

Summary

The pinned pywin32==307 constraint causes dependency conflicts with other packages that require newer pywin32 versions.

Problem

When using skelmis-docx alongside packages like mcp (Model Context Protocol SDK) which requires pywin32>=310, the dependency resolver fails:

Because skelmis-docx==2.5.0 depends on pywin32{sys_platform == 'windows'}==307
and mcp>=1.25.0 depends on pywin32{sys_platform == 'win32'}>=310,
these packages are incompatible.

Solution

Change pywin32==307 to pywin32>=307 to allow compatibility with newer pywin32 versions while maintaining the minimum version requirement.

Testing

  • The change only affects Windows platforms (sys_platform == 'windows')
  • pywin32 307+ maintains backward compatibility
  • This is a minimal, low-risk change

Use Case

I'm integrating skelmis-docx into gemini-research-mcp for exporting research reports to DOCX format with TOC support. The MCP SDK has a strict pywin32 requirement that conflicts with the pinned version.

The pinned pywin32==307 causes dependency conflicts with other packages
like mcp (Model Context Protocol) which requires pywin32>=310.

Changing to >=307 allows compatibility with newer pywin32 versions
while maintaining the minimum version requirement.
gfortaine added a commit to machinemates-ai/gemini-research-mcp that referenced this pull request Jan 20, 2026
Switched from python-docx to skelmis-docx (enhanced fork with native TOC,
bookmarks, hyperlinks, and PDF export support). Using fortaine fork
temporarily until pywin32 version constraint is relaxed upstream.

- Export DOCX documents now include auto-generated Table of Contents
- TOC entries link directly to sections in the document
- Updated tests to use skelmis.docx import path
- export_research_session now uses AI-powered semantic session matching
- Both research_followup and export_research_session fall back to most
  recent session when no match found (handles generic queries like 'elaborate')
- Added 11 tests for session matching behavior and fallback logic

Upstream PR: Skelmis/python-docx#30
gfortaine added a commit to machinemates-ai/gemini-research-mcp that referenced this pull request Jan 20, 2026
* docs: add PyPI and Python version badges to README

* fix: correct client health tracking in retry loops

- Refresh client inside initial retry loop so health-based refreshes
  take effect after consecutive failures
- Validate resume_stream is not None before recording success in
  reconnect path to prevent incorrect health metrics

Fixes issues identified in code review:
- Client was captured once before retry loop, preventing refresh
- Success was recorded before validating stream was iterable

* feat: simplify API to 4 tools with proper session context

- Add summary and report_text fields to ResearchSession
- research_deep now auto-saves 300-char summary for discovery
- list_research_sessions shows query + summary for each session
- Remove 4 unnecessary tools: get/update/delete/cleanup sessions
- Rename summary() method to short_description() to avoid conflict
- Update server instructions to document 4-tool workflow

API surface reduced from 8 to 4 tools:
- research_web: fast lookup (5-30s)
- research_deep: comprehensive research (3-20 min)
- research_followup: continue old research by interaction_id
- list_research_sessions_tool: discover sessions by query + summary

* feat: use Gemini 3.0 Flash for AI-powered session summaries

- Add generate_summary() using gemini-3.0-flash with minimal thinking
- Replace naive truncation with proper 2-3 sentence AI summary
- Add GEMINI_SUMMARY_MODEL env var for customization
- Cost: ~$0.0003 per summary (~100 output tokens)
- Fallback to truncation if AI call fails

* feat: semantic session matching for research_followup

User journey now works seamlessly:
1. User: "What research did I do about quantum?"
2. Agent: list_research_sessions → JSON with queries + summaries
3. Agent summarizes sessions to user
4. User: "Tell me more about surface codes"
5. Agent: research_followup(query="surface codes") → auto-matches session

Implementation:
- list_research_sessions_tool now returns JSON (parseable by agents)
- research_followup accepts query-first, interaction_id is optional
- semantic_match_session() uses Gemini 3.0 Flash (minimal thinking)
  to find best matching session from summaries
- Cost: ~$0.0003 per match call
- Fallback: error message with guidance if no match found

* feat: add export tool with DOCX/Markdown/JSON support

- Add export_research_session tool for sharing research reports
- Support Markdown (.md), JSON (.json), and Word (.docx) formats
- DOCX uses python-docx with proper heading, list, and inline formatting
- Add python-docx as optional dependency [docx] extra

Bug fixes from review:
- Guard auto-save session against filesystem errors (Medium)
- Fix GEMINI_RESEARCH_STORAGE_PATH handling for ~ and directories (Medium)
- Fix list_sessions_async limit handling for 0/negative values (Low)
- Add explicit KeyError for missing required fields in from_dict (Low)
- Fix config comment about client refresh behavior (Low)
- Remove unused imports from tests (Low)

New tests: 26 export tests covering all formats
Total: 134 tests passing, mypy clean

* feat(export): use skelmis-docx for TOC and hyperlink support

Switched from python-docx to skelmis-docx (enhanced fork with native TOC,
bookmarks, hyperlinks, and PDF export support). Using fortaine fork
temporarily until pywin32 version constraint is relaxed upstream.

- Export DOCX documents now include auto-generated Table of Contents
- TOC entries link directly to sections in the document
- Updated tests to use skelmis.docx import path
- export_research_session now uses AI-powered semantic session matching
- Both research_followup and export_research_session fall back to most
  recent session when no match found (handles generic queries like 'elaborate')
- Added 11 tests for session matching behavior and fallback logic

Upstream PR: Skelmis/python-docx#30

* fix: update client health during polling to prevent premature refresh

The polling loop in deep research now calls _record_client_success() after
each successful poll. This prevents the client from being refreshed mid-
research due to appearing 'idle' (idle_time > CLIENT_MAX_AGE_SECONDS / 2).

Previously, long polling sessions (>30 min) could trigger client refresh
because last_request_at wasn't being updated during successful polls.

* feat(export): add MCP Resources for binary export downloads

- Add ephemeral export cache with 1-hour TTL
- Create research://exports/{id} for binary blob downloads
- Create research://exports for listing available exports
- Update export tool to return resource URI instead of base64
- VS Code Copilot can now 'Save' or drag-drop exports directly
- Add 7 tests for export cache functionality
- Remove unused imports (export_to_docx, export_to_json, export_to_markdown)

* style(tests): apply ruff auto-fixes and format improvements

- Combine nested with statements in test_config.py
- Add noqa comments for intentional late imports in test_streaming.py
- Apply consistent formatting across test files

* fix: address code review findings

- Pin skelmis-docx to commit SHA for reproducible builds
- Add defensive handling for corrupted storage entries in list_sessions_async
- Fix import error message to use correct install command
- Fix _add_formatted_text docstring to match actual regex behavior
- Add summary truncation in semantic_match_session to prevent context overflow
- Add test for corrupted session handling

* feat: enhanced DOCX export with cover page, static TOC, styled metadata

- Add cover page with centered title and research metadata
- Replace dynamic Word TOC with static TOC (no manual update required)
- Add metadata table with styled cells and shading
- Add executive summary with highlighted box formatting
- Implement blue color scheme for headings
- Support EmbeddedResource pattern for VS Code Save As functionality
Copy link
Owner

@Skelmis Skelmis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure why ci is failing on linux given this is a windows change but sounds good to me!

@Skelmis Skelmis merged commit cfb3d23 into Skelmis:master Jan 20, 2026
4 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants